# encoding: utf-8
require "erb"
class CreatTemplate
  @obj=nil

  def creatCodeFile(templatefileName, creatFileName, path="../template/", binding)
    file = "../views/"+creatFileName
    f = File.new(file, "w")
    File.open( path+templatefileName ) { |fh|
      rhtml = ERB.new( fh.read )
      # f.print ERB.result( binding )
      f.print rhtml.result
      puts "finished"
    }
  end
  def showHtml(templatefileName, path, binder)
    @obj=binder
    bindingobj=self.send(:binding)
    puts  path+"/views/"+templatefileName+".erb"
    File.open( path+"/views/"+templatefileName+".erb" ) { |fh|
      rhtml = ERB.new( fh.read )
      rhtml.result(bindingobj)
    }
  end
end